<?php
/**
 * MatchDart! is a darts event ranking table component for joomla
 * 
 * @version		2.0.1 | $Id: admin.matchdart.php 92 2009-08-28 10:34:11Z mwi.nor $
 * @package		MatchDart!
 * @subpackage	Admin
 * @copyright	Copyright (C) 2005 - 2009 Marco Wilde. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * @author		Marco Wilde, <mailto://info@matchdart.de>
 * @link		http://www.matchdart.de
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Require the base controller
require_once( JPATH_COMPONENT.DS.'controller.php' );

// build submenu
$subMenus = array(
	'MD_NAVEVENTS' => 'events',
	'MD_NAVSEASONS' => 'seasons',
	'MD_NAVPLAYERS' => 'players',
	'MD_NAVTEAMS' => 'teams',
	'MD_NAVVENUES' => 'venues',
	'MD_NAVMATCHES' => 'matches',
	'MD_NAVPENALTIES' => 'penalties');

foreach ($subMenus as $name => $extension) {
	JSubMenuHelper::addEntry(JText::_( $name ), 'index.php?option=com_matchdart&controller='.$extension);
}
JSubMenuHelper::addEntry(JText::_( 'MD_NAVABOUT' ), 'index.php?option=com_matchdart&task=about');

// Require specific controller if requested
if($controller = JRequest::getWord('controller')) {
	$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
	if (file_exists($path)) {
		require_once $path;
	} else {
		$controller = '';
	}
}

// Create the controller
$classname	= 'MatchdartController'.$controller;
$controller	= new $classname( );

// Perform the Request task
$controller->execute( JRequest::getVar( 'task' ) );

// Redirect if set by the controller
$controller->redirect();